package guoanmaker.operator.business.repository;

import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.transaction.annotation.Transactional;

import guoanmaker.operator.business.model.OperatorActivityPrice;

public interface OperatorActivityPriceRepository extends JpaRepository<OperatorActivityPrice, String>, JpaSpecificationExecutor<OperatorActivityPrice>{
	@Query("select oap from OperatorActivityPrice oap where oap.activityId=:activityId ORDER BY oap.weight ASC ")
	public List<OperatorActivityPrice> selectOperatorActivityPrice(@Param("activityId")String activityId);
	
	@Transactional
	@Modifying
	@Query("UPDATE OperatorActivityPrice set sellNum=sellNum+:num  where id=:id ")
	public int updateAddSellNum(@Param("id")String id,@Param("num")Integer num)throws Exception;
	
	@Transactional
	@Modifying
	@Query("UPDATE OperatorActivityPrice set sellNum=sellNum-:num  where id=:id ")
	public int updateRemoveSellNum(@Param("id")String id,@Param("num")Integer num)throws Exception;
}
